{layout name="../../admin/view/layout/main" /}
<div class="card">
    <div class="card-body">
        <div class="alert alert-primary" role="alert">
            请把控制器放在模块的event/目录下<br/>
            <span style="color: gray;">时间固定为一分钟访问一次，url为：{$domain}/cron/</span><br/>
            <span style="color: gray;">如果间隔的时间不为一分钟的话，请在事件控制器代码中实现。</span>
          </div>
        <table id="table" class="table table-bordered table-hover table-striped lyear-table">
            <thead class="">
                <tr>
                    <th>任务名称</th>
                    <th>控制器</th>
                    <th>状态</th>
                </tr>
            </thead>
            <tbody>
                {foreach $items as $item}
                <tr>
                    <td>{$item.name}</td>
                    <td>{$item.callback}</td>
                    <td>
                        <a href="javascript:;" onclick="setStatus('{$item.callback}');">
                            {if $item.status == 0}
                            <span class="badge bg-success">正常</span>
                            {else /}
                            <span class="badge bg-danger">停用</span>
                            {/if}
                        </a>
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
</div>
<script>
    function setStatus(callback) {
        xp_confirm("{:url('market/index/task')}", {name: '{$app.name}', callback: callback}, function (){
            location.reload();
        }); 
    }
</script>